home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / VLA_FONT.ZIP / HSCRCYC2.ASM < prev    next >
Assembly Source File  |  1993-09-27  |  11KB  |  496 lines

  1.     IDEAL
  2.     DOSSEG
  3.     MODEL SMALL
  4.     STACK 200h
  5.     CODESEG
  6.     p386
  7.     
  8.     ASSUME CS:@CODE, DS:@CODE
  9. ────────────────────────────────────────────────────────────────────────────
  10. STRUC VCHHDR
  11.     Ident   db  "VLACH"
  12.     From    db  ?
  13.     X       db  ?
  14.     Y       db  ?
  15.     NumChar db  ?
  16. ENDS
  17.  
  18. STRUC Pal
  19.     R       db  ?
  20.     G       db  ?
  21.     B       db  ?
  22. ENDS
  23. ────────────────────────────────────────────────────────────────────────────
  24. INCLUDE "MODEX.INC"
  25.  
  26. FileName_VCH    db      "palFont.VCH",0
  27. FileName_PAL    db      "palFont.PAL",0
  28.  
  29. Seg_VCH         dw      0
  30.  
  31. Palette         Pal     256 dup (<>)
  32.  
  33. LABEL BarPal Pal
  34.     i = 0
  35.     REPT 4
  36.         Pal <i,i/3,i/2>
  37.         i=i+2
  38.     ENDM
  39.     REPT 8
  40.         Pal <i,i/3,i/2>
  41.         i=i+3
  42.     ENDM
  43.     REPT 4
  44.         Pal <i,i/3,i/2>
  45.         i=i+2
  46.     ENDM
  47.     REPT 4
  48.         Pal <i,i/3,i/2>
  49.         i=i-2
  50.     ENDM
  51.     REPT 8
  52.         Pal <i,i/3,i/2>
  53.         i=i-3
  54.     ENDM
  55.     REPT 4
  56.         Pal <i,i/3,i/2>
  57.         i=i-2
  58.     ENDM
  59.  
  60. VCHHEADER       VCHHDR  <>
  61. CharWidths      db      256 dup (0)
  62.  
  63. TheMessage      db      "  WOW!! THIS SCROLLER LOOKS REALLY COMPLICATED! "
  64.                 db      "  BUT IT ISN'T..  IT'S A PALETTE ROTATE AND A "
  65.                 db      "SCROLLER.  KINDA WEIRD, EH?  "
  66.                 db      "  RESOLUTION IS: 256X200 PLANAR WITH A CELL HEIGHT "
  67.                 db      "OF 1 (2 SCAN LINES PER PIXEL) AND THE VIRTUAL WIDTH "
  68.                 db      "IS 520 PIXELS (2X256 + 8, TO HIDE THE AREA THAT'S BEING "
  69.                 db      "WORKED ON)          "
  70.                 db      0
  71.  
  72. MsgOff          dw      offset TheMessage
  73. CharOff         dw      0       ;offset to current column to draw of chr
  74. XYsize          dw      ?       ;number of bytes in a char
  75. CurColumn       db      1
  76. DestOff         dw      0
  77. SCReenWidth     =       130
  78.  
  79. TempBG          db      128
  80. ────────────────────────────────────────────────────────────────────────────
  81.     Numcolors   dw  32      ;# of colors to rotate
  82.     NumColors3  dw  32*3    ;# of colors*3
  83.     StartAt     db  128     ;color to start rotate at
  84.     PalIndex    dw  0       ;color to start write at- increased every time
  85.                             ;to produce the rotating effect
  86.     PalIndexVel dw  2       ;amount PalIndex Changes for each screen
  87.  
  88.     PalOffset   dw  offset BarPal
  89. ────────────────────────────────────────────────────────────────────────────
  90. PROC RotatePalette NEAR
  91.     pusha
  92.  
  93.     call  WritePalette
  94.  
  95.     mov   ax,[PalIndexVel]
  96.     add   [PalIndex],ax    ;change the palette index
  97.  
  98.     mov   ax,[PalIndex]    ;are we over the number of colors?
  99.     mov   bx,[NumColors]
  100.  
  101.     cmp   ax,bx
  102.     jl    NotTooHigh
  103.     sub   [PalIndex],bx    ;add [Numcolors] to the index
  104.     jmp   NotTooLow
  105. NotTooHigh:
  106.     cmp   ax,0
  107.     jge   NotTooLow
  108.     add   [PalIndex],bx    ;subtract [Numcolors] to the index
  109. NotTooLow:
  110.  
  111.     popa
  112.     ret
  113. ENDP
  114.  
  115. PROC WritePalette NEAR        
  116.     cld
  117.  
  118.     mov   dx,[PalIndex]
  119.     mov   bx,dx
  120.     add   bx,bx           ;This just multiplies
  121.     add   bx,dx           ;bx by three ( bx = bx + 2*bx )
  122.  
  123.     mov   si,[PalOffset]
  124.     mov   dx,03c8h
  125.     mov   ax,[PalIndex]
  126.     add   al,[StartAt]
  127.     out   dx,al           ;start writing at [PalIndex]+[StartAt]
  128.     inc   dx
  129.     mov   cx,[NumColors3]
  130.     sub   cx,bx           ;get the number of colors to write
  131.     rep outsb
  132.  
  133.     mov   al,[StartAt]
  134.     dec   dx              ;point to palette index
  135.     out   dx,al           ;out the number we want to start writing at 
  136.     inc   dx
  137.     mov   cx,bx           ;get the number of colors to write
  138.     rep outsb             ;note that SI is already where we want it
  139.  
  140.     ret
  141. ENDP         ;well, that's all there is to it
  142.  
  143.     ────────────────────────────────────────────────────────────────────
  144.     ; Load in the font named in FileName_VCH and loads in the Palette
  145.     ; named in FileName_PAL. 
  146.     ;
  147.     ; Returns CF = 1 if there was an error
  148.     ────────────────────────────────────────────────────────────────────
  149. PROC LoadFont NEAR
  150.     pusha
  151.     push    ds
  152.  
  153.     mov     ax,cs
  154.     mov     ds,ax
  155.     mov     dx,offset FileName_PAL      ;open the palette file
  156.     mov     ax,3d00h
  157.     int     21h
  158.     jc      @@Error
  159.     mov     bx,ax
  160.  
  161.     mov     dx,offset Palette           ;read in the palette
  162.     mov     cx,768
  163.     mov     ah,3fh
  164.     int     21h
  165.  
  166.     mov     ah,3eh                      ;close PAL file
  167.     int     21h
  168.  
  169.     mov     dx,offset FileName_VCH      ;open VCH file
  170.     mov     ax,3d00h
  171.     int     21h
  172.     jc      @@Error
  173.     mov     bx,ax
  174.  
  175.     mov     dx,offset VCHHeader         ;load in the header
  176.     mov     cx,size VCHHDR
  177.     mov     ah,3fh
  178.     int     21h
  179.  
  180.     mov     al,[VCHHEADER.X]            ;calc data size
  181.     mul     [VCHHEADER.Y]
  182.     mov     [XYsize],ax
  183.     movzx   cx,[VCHHEADER.NumChar]
  184.     mul     cx
  185.     mov     cx,ax
  186.  
  187.     mov     ax,[cs:SEG_VCH]             ;move SEG_VCH into DS, but be sure
  188.     or      ax,ax                       ;the segment isn't 0
  189.     stc
  190.     je      @@Error
  191.     mov     ds,ax
  192.     xor     dx,dx                       ;load in the data
  193.     mov     ah,3fh
  194.     int     21h
  195.  
  196.     mov     ax,cs
  197.     mov     ds,ax
  198.     mov     dx,offset CharWidths
  199.     movzx   cx,[VCHheader.NumChar]
  200.     mov     ah,3fh
  201.     int     21h                         ;read in widths of chars
  202.  
  203.     mov     ah,3eh                      ;close VCH file
  204.     int     21h
  205.     clc
  206.  
  207. @@Error:
  208.  
  209.     pop     ds
  210.     popa
  211.     ret
  212. ENDP
  213.     ────────────────────────────────────────────────────────────────────
  214.     ;Starts the next letter in the message
  215.     ────────────────────────────────────────────────────────────────────
  216. PROC NewChar NEAR
  217.     pusha
  218.     push    ds
  219.     mov     ax,cs
  220.     mov     ds,ax
  221.  
  222.     mov     si,[MsgOff]     ;get the offset to the next char
  223. @@MsgLoop:
  224.     lodsb
  225.     or      al,al
  226.     jne     @@IsaChar
  227.     mov     si,offset TheMessage
  228.     jmp short @@MsgLoop
  229.  
  230. @@IsaChar:
  231.     mov     ah,[VCHHEADer.From]
  232.     add     ah,[VCHHEADer.NumChar]
  233.     cmp     al,[VCHHEADer.FROM]
  234.     jb      @@MsgLoop
  235.     cmp     al,ah
  236.     ja      @@MsgLoop
  237.  
  238.     mov     [MsgOff],si
  239.     sub     al,[VCHheader.From]
  240.     movzx   ax,al
  241.     mov     bx,ax
  242.     mul     [XYsize]
  243.     mov     [CharOff],ax
  244.     
  245.     mov     al,[CharWidths + bx]
  246.     mov     [CurColumn],al
  247.     
  248.     pop     ds
  249.     popa
  250.     ret
  251. ENDP
  252.     ────────────────────────────────────────────────────────────────────
  253.     ; Draws the Next column onto the screen, calls NewChar if done with
  254.     ; current character
  255.     ────────────────────────────────────────────────────────────────────
  256. PROC DrawColumn NEAR
  257.     pusha
  258.     push    ds es fs
  259.     mov     ax,cs
  260.     mov     ds,ax
  261.  
  262.     cmp     [TempBG],128+32
  263.     jb      @@BGok
  264.     mov     [TempBG],128
  265. @@BGok:
  266.  
  267.     mov     bx,[DestOff]
  268.     add     bx,2
  269.     @Set_Start_Offset
  270.  
  271.     sub     [CurColumn],4
  272.     jg      @@NoNew
  273.  
  274.     call    NewChar
  275.  
  276. @@NoNew:
  277.     mov     fs,[SEG_VCH]
  278.     mov     es,[VGASEG]
  279.  
  280.     mov     bp,SCReenWidth         ;screen width
  281.  
  282.     mov     dx,SC_Index
  283.     mov     ax,0102h
  284.     out     dx,ax
  285.  
  286.     movzx   dx,[VCHheader.X]
  287.     movzx   cx,[VCHheader.Y]
  288.     mov     si,[CharOff]    ;fs:si points to the data
  289.     mov     di,[DestOff]
  290. @@Zloop:
  291.     mov     al,[fs:si]
  292.     or      al,al
  293.     jne     short @@ok1
  294.     mov     al,[cs:TempBG]
  295. @@ok1:
  296.     mov     [es:di],al
  297.     mov     [es:di+SCReenWidth/2],al
  298.     add     di,bp
  299.  
  300.     add     si,dx
  301.  
  302.     loop    @@ZLoop
  303.  
  304.     inc     [cs:TempBG]
  305.     
  306.     mov     dx,SC_Index
  307.     mov     ax,0202h
  308.     out     dx,ax
  309.  
  310.     movzx   dx,[VCHheader.X]
  311.     movzx   cx,[VCHheader.Y]
  312.     mov     si,[CharOff]    ;fs:si points to the data
  313.     inc     si
  314.     mov     di,[DestOff]
  315. @@Zloop2:
  316.     mov     al,[fs:si]
  317.     or      al,al
  318.     jne     short @@ok2
  319.     mov     al,[cs:TempBG]
  320. @@ok2:
  321.     mov     [es:di],al
  322.     mov     [es:di+SCReenWidth/2],al
  323.     add     di,bp
  324.  
  325.     add     si,dx
  326.  
  327.     loop    @@ZLoop2
  328.     
  329.     inc     [cs:TempBG]
  330.  
  331.     mov     dx,SC_Index
  332.     mov     ax,0402h
  333.     out     dx,ax
  334.  
  335.     movzx   dx,[VCHheader.X]
  336.     movzx   cx,[VCHheader.Y]
  337.     mov     si,[CharOff]    ;fs:si points to the data
  338.     add     si,2
  339.     mov     di,[DestOff]
  340. @@Zloop3:
  341.     mov     al,[fs:si]
  342.     or      al,al
  343.     jne     short @@ok3
  344.     mov     al,[cs:TempBG]
  345. @@ok3:
  346.     mov     [es:di],al
  347.     mov     [es:di+SCReenWidth/2],al
  348.     add     di,bp
  349.  
  350.     add     si,dx
  351.  
  352.     loop    @@ZLoop3
  353.  
  354.     inc     [cs:TempBG]
  355.  
  356.     mov     dx,SC_Index
  357.     mov     ax,0802h
  358.     out     dx,ax
  359.  
  360.     movzx   dx,[VCHheader.X]
  361.     movzx   cx,[VCHheader.Y]
  362.     mov     si,[CharOff]    ;fs:si points to the data
  363.     add     si,3
  364.     mov     di,[DestOff]
  365. @@Zloop4:
  366.     mov     al,[fs:si]
  367.     or      al,al
  368.     jne     short @@ok4
  369.     mov     al,[cs:TempBG]
  370. @@ok4:
  371.     mov     [es:di],al
  372.     mov     [es:di+SCReenWidth/2],al
  373.     add     di,bp
  374.  
  375.     add     si,dx
  376.  
  377.     loop    @@ZLoop4
  378.  
  379.     inc     [cs:TempBG]
  380.  
  381.     inc     [DestOff]
  382.     cmp     [DestOff],ScreenWidth/2
  383.     jb      @@okok
  384.  
  385.     mov     [DestOff],0
  386.  
  387. @@okok:
  388.     add     [CharOff],4
  389.  
  390.     pop     fs es ds
  391.     popa
  392.     ret
  393. ENDP
  394.  
  395. HPPPOS  db  0
  396.  
  397. PROC Scrollit NEAR
  398.     pusha
  399.  
  400.     mov     ah,[HPPpos]
  401.     add     ah,2 *2
  402.     mov     [HPPpos],ah
  403.     cmp     ah,8
  404.     jb      @@JustSetIt
  405.     sub     ah,8
  406.     mov     [HPPpos],ah
  407.  
  408.     call    DrawColumn
  409.  
  410. @@JustSetIt:
  411.     mov     ah,[HPPpos]
  412.     @Set_HPP
  413.  
  414.     popa
  415.     ret
  416. ENDP
  417.  
  418. PROC FilterFont NEAR
  419.     pusha
  420.     push    ds es
  421.  
  422.     mov     ds,[cs:SEG_VCH]
  423.     mov     es,[cs:SEG_VCH]
  424.     xor     di,di
  425.     xor     si,si
  426.  
  427.     mov     al,[cs:VCHHEADER.X]            ;calc data size
  428.     mul     [cs:VCHHEADER.Y]
  429.     mov     [cs:XYsize],ax
  430.     movzx   cx,[cs:VCHHEADER.NumChar]
  431.     mul     cx
  432.     mov     cx,ax
  433.  
  434. @@FiltLoop:
  435.     lodsb
  436.     cmp     al,1
  437.     je      short @@ok
  438.     xor     al,al
  439. @@ok:
  440.     stosb
  441.     loop    @@FiltLoop
  442.  
  443.     pop     es ds
  444.     popa
  445.     ret
  446. ENDP
  447. ────────────────────────────────────────────────────────────────────────────
  448. START:
  449.     mov     ax,cs
  450.     mov     ds,ax
  451.  
  452.     mov     ax,ss
  453.     mov     bx,sp
  454.     add     bx,15
  455.     shr     bx,4
  456.     add     ax,bx
  457.     mov     [SEG_VCH],ax
  458.  
  459.     @SetModeX m256x200x256, 520
  460.  
  461.     call    LoadFont
  462.     call    FilterFont
  463.  
  464.     mov     si,offset Palette
  465.     mov     cx,256
  466.     mov     al,0
  467.     @WritePalette
  468.     
  469.     mov     dx,CRTC_Index
  470.     mov     al,9
  471.     mov     ah,1    ;each dot is 2 high (use HEIGHT-1)
  472.     out     dx,ax
  473.  
  474.     @SET_PPC    ;set Pixel Panning Compatibility
  475.                 ;so the split screen, if I had one, would not be disturbed.
  476.                 
  477. @@MainLoop:
  478.     @FullVertWait
  479.     call    RotatePalette
  480.     call    Scrollit
  481.  
  482.     ;call    DrawColumn
  483.  
  484.     mov     ah,1
  485.     int     16h
  486.     jz      @@MainLoop
  487.  
  488.     mov     ah,0
  489.     int     16h
  490.  
  491.     mov     ax,3
  492.     int     10h
  493.     mov     ax,4c00h
  494.     int     21h
  495. END START
  496.